using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;

public class DashSkill : SkillBase
{
    public bool dashUnlocked { get; private set; }
    public bool cloneOnDashUnlocked { get; private set; }
    public bool cloneOnArrivalUnlocked { get; private set; }
    [SerializeField] private SkillTreeUISlot dashUnlockedButton;
    [SerializeField] private SkillTreeUISlot cloneOnDashUnlockedButton;
    [SerializeField] private SkillTreeUISlot cloneOnArrivalUnlockedButton;
    public override bool CanUseSkill()
    {
        GameUI.CallDashCooldownEvent();
        return base.CanUseSkill();
    }
    protected override void Start()
    {
        base.Start();

        dashUnlockedButton.GetComponent<Button>().onClick.AddListener(UnlockDash);
        cloneOnDashUnlockedButton.GetComponent<Button>().onClick.AddListener(UnlockCloneOnDash);
        cloneOnArrivalUnlockedButton.GetComponent<Button>().onClick.AddListener(UnlockCloneOnArrival);
        dashUnlocked = dashUnlockedButton.unlocked;
        cloneOnDashUnlocked = cloneOnDashUnlockedButton.unlocked;
        cloneOnArrivalUnlocked = cloneOnArrivalUnlockedButton.unlocked;
    }
    private void UnlockDash()
    {
        dashUnlockedButton.UnLockedSkillSolt();
        if (dashUnlockedButton.unlocked)
            dashUnlocked = true;
    }

    private void UnlockCloneOnDash()
    {
        cloneOnDashUnlockedButton.UnLockedSkillSolt();
        if (cloneOnDashUnlockedButton.unlocked)
            cloneOnDashUnlocked = true;
    }
    private void UnlockCloneOnArrival()
    {
        cloneOnArrivalUnlockedButton.UnLockedSkillSolt();
        if (cloneOnArrivalUnlockedButton.unlocked)
            cloneOnArrivalUnlocked = true;
    }
    public void CloneOnDashStart()
    {
        if (cloneOnDashUnlocked)
            SkillManager.Instance.clone.CreateClone(player.transform, Vector3.zero);
    }
    public void CloneOnDashOver()
    {
        if (cloneOnArrivalUnlocked)
            SkillManager.Instance.clone.CreateClone(player.transform, Vector3.zero);
    }
}